#include "point.h"

Point::Point(void):
    id(0), name(cUNNAMED), coord(0, 0), fileList()
{}

Point::Point(const QString& aName, const unsigned long& aID, const GeoCoordinates& aCoord):
    id(aID), name(aName), coord(aCoord.GetLatitude(), aCoord.GetLongitude()), fileList()
{}

Point::Point(const QString& aName, const unsigned long& aID, const double& aLatitude, const double& aLongitude):
    id(aID), name(aName), coord(aLatitude, aLongitude), fileList()
{}

Point::~Point()
{
    name.clear();
    fileList.clear();
}

void Point::ClearPoint(void)
{
    name = cUNNAMED;
    coord.SetLatitude(0);
    coord.SetLongitude(0);
    fileList.clear();
}

bool Point::SetName(const QString& aName)
{
    if(!aName.isEmpty())
    {
        name = aName;
        return true;
    }
    else
        return false;
}

QString Point::GetName(void) const
{
    return name;
}

void Point::SetID(const unsigned long& aID)
{
    id = aID;
}

unsigned long Point::GetID(void) const
{
    return id;
}

void Point::SetCoordinates(const double& aLatitude, const double& aLongitude)
{
    coord.SetLatitude(aLatitude);
    coord.SetLongitude(aLongitude);
}

void Point::SetCoordinates(const GeoCoordinates& aCoord)
{
    coord = aCoord;
}

GeoCoordinates Point::GetCoordinates(void) const
{
    return coord;
}

bool Point::AddFile(const QString& aFile)
{
    if(aFile.compare(""))
    {
        fileList.push_back(const_cast <QString&> (aFile));
        return true;
    }
    else
        return false;
}

unsigned long Point::GetFileCount(void) const
{
    return fileList.size();
}

QString Point::GetFileName(const int& aNumber) const
{
    if(aNumber >= 0 && aNumber < fileList.size())
        return fileList[aNumber];
    return NULL;
}

QList <QString> Point::GetFileList(void) const
{
    return fileList;
}

void Point::DeleteFile(const int& aNumber)
{
    if(aNumber >= 0 && aNumber < fileList.size())
        fileList.removeAt(aNumber);
}
